DEBUG_MODE = True 
import os
from ..settings import DATABASE as db
# 构建 Tortoise ORM 配置，确保模型路径是字符串形式

def discover_models(directory):
    models = []
    for root, _, files in os.walk(directory):
        for file in files:
            if file.endswith(".py") and file != "__init__.py":
                module_path = os.path.join(root, file).replace("/", ".").replace("\\", ".").replace(".py", "")
                models.append(module_path)
    return models

models = discover_models("app/models")
print(models)
TORTOISE_ORM = {
    "connections": {
        "default": f"mysql://{db['user']}:{db['password']}@{db['host']}:{db['port']}/{db['database']}"
    },
    "apps": {
        "models": {
            "models": models + ["aerich.models"],
            "default_connection": "default",
        },
    },
    "use_tz": False,
    "timezone": "Asia/Shanghai"
}
